{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {
    "scrolled": true
   },
   "outputs": [],
   "source": [
    "import pandas as pd \n",
    "import math\n",
    "import numpy as np\n",
    "from statsmodels.graphics.tsaplots import plot_acf, plot_pacf\n",
    "from statsmodels.tsa.stattools import adfuller as adf \n",
    "from statsmodels.stats.diagnostic import acorr_ljungbox as lbtest\n",
    "from statsmodels.tsa.arima.model import ARIMA\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "P-value = 0.37739172374340485\n"
     ]
    },
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAX8AAAEICAYAAAC3Y/QeAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADl0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uIDIuMi4yLCBodHRwOi8vbWF0cGxvdGxpYi5vcmcvhp/UCwAAIABJREFUeJzt3XuYHNV95vHvOzMaXRFCSAJ0Q8TIBNlrCzIPMvE6YQ1swPGCnzxeB5LYkMVWvAlxnNgb48s6WSdxvPF6401MLgrGYHwljuMoDgnGSth4vcAisEIsERkFA5IlISE0kmZGMz3d9ds/qlq0WjOaS9dMd0+9n+fpZ7qqT9U5zeWt6lOn6igiMDOzYulodgPMzGz6OfzNzArI4W9mVkAOfzOzAnL4m5kVkMPfzKyAHP5m00TSM5KumuS2r5O0M+82WXE5/K1lSHpQ0mFJsyewTUi6cCrb1Qz13ysivhURFzWzTTazOPytJUhaA7wOCOC6pjZmDJK6xrPOrJU5/K1VvA14GLgLuKm6Mvs18Paa5Zsl/Z/s/T9mq/9JUp+kn87Wv0PSLkkvStosaXnN9q+Q9ED22fOSPpCtny3pk5L2Zq9PVn+BSLpC0h5J75O0H/jMSOuysm+UtE1Sr6T/K+lVI31ZSZdJeigrt0/SpyR1j/a9qvXVbH9x9s+mV9J2S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432x288 with 1 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "df = pd.read_csv(\"./EX.csv\")\n",
    "tsdata = df\n",
    "tsdata[\"Year\"] = pd.to_datetime(tsdata[\"Year\"], format=\"%Y\")\n",
    "tsdata.index = tsdata[\"Year\"]\n",
    "del tsdata[\"Year\"]\n",
    "\n",
    "\n",
    "training = tsdata.truncate(after='2004-1-1')\n",
    "testing = tsdata.truncate(before='2005-1-1')\n",
    "plot_acf(training, lags=12)\n",
    "test = adf(training, autolag=\"AIC\")\n",
    "print(\"P-value = {}\".format(test[1]) )\n",
    "# 不平稳"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {
    "scrolled": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "P-value = 0.0001998333573817075\n"
     ]
    },
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAX8AAAEICAYAAAC3Y/QeAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADl0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uIDIuMi4yLCBodHRwOi8vbWF0cGxvdGxpYi5vcmcvhp/UCwAAHChJREFUeJzt3X2UHNV95vHvMy2NXhCyAI1Ab0jEyATBMYKdw0tYO4qBE+F4wWeP46DYBrLYMmvjl4SNDbaXeMnG8SabtdeBJNYaDMYYTBwnlokcjIVZe73AIrBMkBRZCgY0CNDwIoM00sx092//6Bqpp9Wj6emume6eej7nzJmuqlt1b4/UT1XfqrqliMDMzLKlo9kNMDOziefwNzPLIIe/mVkGOfzNzDLI4W9mlkEOfzOzDHL4m00QSU9LurDOdd8iaVvabbLscvhby5D0oKRXJU0bwzoh6eTxbFczVL6viPhxRJzSzDbZ5OLwt5YgaSnwFiCAS5ramFFImlLLPLNW5vC3VnE58DBwG3DF0Mzk28D7y6avlPR/ktc/Smb/TNJeSb+TzP+ApB2SXpG0TtK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0R+ARQbHZD6vQrQC/w1aTr6iuSjmp2o8YiIp4D/julYVeeB34ZEe36PI1Rh45vM/8B+F6zGzHZwr/amNFteS2rpFnA3wEfj4jXmt2eWkl6B7A7Ih5rdlsaMAU4C/jriDgT2EfrdzUMk/SLXwqcBCwAjpL03ua2yiR9mlLX7p3NbstkC/8eYHHZ9CLa4KtuJUlTKQX/nRHx7Wa3Z4zOBy6R9DSlbre3Sfp6c5s0Zj1AT0QMfeP6FqWdQTu5EPhFRPRGxCDwbeDXmtymer2YDBnPEYaOb3mSrgDeAbwnWuAGq8kW/o8CyySdJKmT0gmudU1u05io9MSbW4CtEfE/mt2esYqI6yNiUUQspfT3fyAi2uqIMyJeAHZKOiWZdQGwpYlNqsezwLmSZib/py6gzU5alxkaOh5GGDq+1UlaBXwSuCQi+prdHphk4Z+cULkGuI/Sf/R7ImJzc1s1ZucD76N0xLwp+Xl7sxuVQR8B7pT0BLAC+FyT2zMmybeWbwGPA/9M6bPeckMMVJJ0F/AQcIqkHklXUXpeyEWStgMXJdMta4T3cBNwNHB/8pn+m6Y2Eg/vYGaWSZPqyN/MzGrj8DczyyCHv5lZBjn8zcwyyOFvZpZBDn8zswxy+JuZZdD/B/jPFpfapytXAAAAAElFTkSuQmCC",
      "text/plain": [
       "<Figure size 432x288 with 1 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAX8AAAEICAYAAAC3Y/QeAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADl0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uIDIuMi4yLCBodHRwOi8vbWF0cGxvdGxpYi5vcmcvhp/UCwAAGhBJREFUeJzt3X+UVPV9//HnaxdXQUQUFiuwAlFCRU+CnP36Izb90qotGCs536YptFGSkNCexqRtPN/4Ix6b2tamTZs0tn6TctSqmKho84MkWJKa0LR+1QMazDdAkJWAu666K4IE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RV8bEVurW1XJLgauIrfFvCX5ubzaRWXQx4GvSPoxsAC4tcr1lCT51vIw8DTw/8j9rdfcJQYKSbofeByYJ6lD0krgs8BlknYClyXTNWuQdfgn4CTge8nf9JerWiS+vIOZWSaNqS1/MzMbHoe/mVkGOfzNzDLI4W9mlkEOfzOzDHL4m5llkMPfzCyD/j84e3cQMUGhRwAAAABJRU5ErkJggg==",
      "text/plain": [
       "<Figure size 432x288 with 1 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "logtrain = np.log(training)\n",
    "dlt = logtrain.diff(periods = 1).dropna()\n",
    "plot_acf(dlt, lags = 12)\n",
    "plot_pacf(dlt, lags = 12)\n",
    "test = adf(dlt, autolag=\"AIC\")\n",
    "print(\"P-value = {}\".format(test[1]) )\n",
    "# print(lbtest(dlt))\n",
    "# p = 1, q = 1"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "metadata": {
    "scrolled": false
   },
   "outputs": [
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "/Users/apple/anaconda3/lib/python3.6/site-packages/statsmodels/tsa/base/tsa_model.py:527: ValueWarning: No frequency information was provided, so inferred frequency AS-JAN will be used.\n",
      "  % freq, ValueWarning)\n",
      "/Users/apple/anaconda3/lib/python3.6/site-packages/statsmodels/tsa/base/tsa_model.py:527: ValueWarning: No frequency information was provided, so inferred frequency AS-JAN will be used.\n",
      "  % freq, ValueWarning)\n",
      "/Users/apple/anaconda3/lib/python3.6/site-packages/statsmodels/tsa/base/tsa_model.py:527: ValueWarning: No frequency information was provided, so inferred frequency AS-JAN will be used.\n",
      "  % freq, ValueWarning)\n",
      "/Users/apple/anaconda3/lib/python3.6/site-packages/statsmodels/tsa/base/tsa_model.py:527: ValueWarning: No frequency information was provided, so inferred frequency AS-JAN will be used.\n",
      "  % freq, ValueWarning)\n",
      "/Users/apple/anaconda3/lib/python3.6/site-packages/statsmodels/tsa/base/tsa_model.py:527: ValueWarning: No frequency information was provided, so inferred frequency AS-JAN will be used.\n",
      "  % freq, ValueWarning)\n",
      "/Users/apple/anaconda3/lib/python3.6/site-packages/statsmodels/tsa/base/tsa_model.py:527: ValueWarning: No frequency information was provided, so inferred frequency AS-JAN will be used.\n",
      "  % freq, ValueWarning)\n"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "                               SARIMAX Results                                \n",
      "==============================================================================\n",
      "Dep. Variable:                     EX   No. Observations:                   54\n",
      "Model:                 ARIMA(1, 0, 0)   Log Likelihood                  25.764\n",
      "Date:                Wed, 13 Apr 2022   AIC                            -45.527\n",
      "Time:                        19:20:40   BIC                            -39.560\n",
      "Sample:                    01-01-1951   HQIC                           -43.226\n",
      "                         - 01-01-2004                                         \n",
      "Covariance Type:                  opg                                         \n",
      "==============================================================================\n",
      "                 coef    std err          z      P>|z|      [0.025      0.975]\n",
      "------------------------------------------------------------------------------\n",
      "const          0.1488      0.036      4.124      0.000       0.078       0.220\n",
      "ar.L1          0.4464      0.133      3.365      0.001       0.186       0.706\n",
      "sigma2         0.0225      0.004      5.037      0.000       0.014       0.031\n",
      "===================================================================================\n",
      "Ljung-Box (L1) (Q):                   0.23   Jarque-Bera (JB):                 0.23\n",
      "Prob(Q):                              0.63   Prob(JB):                         0.89\n",
      "Heteroskedasticity (H):               0.74   Skew:                             0.12\n",
      "Prob(H) (two-sided):                  0.54   Kurtosis:                         3.21\n",
      "===================================================================================\n",
      "\n",
      "Warnings:\n",
      "[1] Covariance matrix calculated using the outer product of gradients (complex-step).\n",
      "\n",
      "\n",
      "                               SARIMAX Results                                \n",
      "==============================================================================\n",
      "Dep. Variable:                     EX   No. Observations:                   54\n",
      "Model:                 ARIMA(0, 0, 1)   Log Likelihood                  26.221\n",
      "Date:                Wed, 13 Apr 2022   AIC                            -46.443\n",
      "Time:                        19:20:40   BIC                            -40.476\n",
      "Sample:                    01-01-1951   HQIC                           -44.142\n",
      "                         - 01-01-2004                                         \n",
      "Covariance Type:                  opg                                         \n",
      "==============================================================================\n",
      "                 coef    std err          z      P>|z|      [0.025      0.975]\n",
      "------------------------------------------------------------------------------\n",
      "const          0.1468      0.030      4.929      0.000       0.088       0.205\n",
      "ma.L1          0.4795      0.117      4.098      0.000       0.250       0.709\n",
      "sigma2         0.0221      0.004      5.578      0.000       0.014       0.030\n",
      "===================================================================================\n",
      "Ljung-Box (L1) (Q):                   0.06   Jarque-Bera (JB):                 0.66\n",
      "Prob(Q):                              0.81   Prob(JB):                         0.72\n",
      "Heteroskedasticity (H):               0.73   Skew:                             0.19\n",
      "Prob(H) (two-sided):                  0.51   Kurtosis:                         3.38\n",
      "===================================================================================\n",
      "\n",
      "Warnings:\n",
      "[1] Covariance matrix calculated using the outer product of gradients (complex-step).\n",
      "\n",
      "\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "/Users/apple/anaconda3/lib/python3.6/site-packages/statsmodels/tsa/base/tsa_model.py:527: ValueWarning: No frequency information was provided, so inferred frequency AS-JAN will be used.\n",
      "  % freq, ValueWarning)\n",
      "/Users/apple/anaconda3/lib/python3.6/site-packages/statsmodels/tsa/base/tsa_model.py:527: ValueWarning: No frequency information was provided, so inferred frequency AS-JAN will be used.\n",
      "  % freq, ValueWarning)\n",
      "/Users/apple/anaconda3/lib/python3.6/site-packages/statsmodels/tsa/base/tsa_model.py:527: ValueWarning: No frequency information was provided, so inferred frequency AS-JAN will be used.\n",
      "  % freq, ValueWarning)\n"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "                               SARIMAX Results                                \n",
      "==============================================================================\n",
      "Dep. Variable:                     EX   No. Observations:                   54\n",
      "Model:                 ARIMA(1, 0, 1)   Log Likelihood                  26.487\n",
      "Date:                Wed, 13 Apr 2022   AIC                            -44.974\n",
      "Time:                        19:20:40   BIC                            -37.018\n",
      "Sample:                    01-01-1951   HQIC                           -41.906\n",
      "                         - 01-01-2004                                         \n",
      "Covariance Type:                  opg                                         \n",
      "==============================================================================\n",
      "                 coef    std err          z      P>|z|      [0.025      0.975]\n",
      "------------------------------------------------------------------------------\n",
      "const          0.1477      0.033      4.470      0.000       0.083       0.212\n",
      "ar.L1          0.1944      0.374      0.520      0.603      -0.538       0.927\n",
      "ma.L1          0.3320      0.357      0.930      0.352      -0.368       1.031\n",
      "sigma2         0.0218      0.004      5.132      0.000       0.013       0.030\n",
      "===================================================================================\n",
      "Ljung-Box (L1) (Q):                   0.01   Jarque-Bera (JB):                 0.34\n",
      "Prob(Q):                              0.93   Prob(JB):                         0.84\n",
      "Heteroskedasticity (H):               0.77   Skew:                             0.16\n",
      "Prob(H) (two-sided):                  0.58   Kurtosis:                         3.22\n",
      "===================================================================================\n",
      "\n",
      "Warnings:\n",
      "[1] Covariance matrix calculated using the outer product of gradients (complex-step).\n",
      "2005 年: 118832.29208248317\n",
      "2006 年: 142238.8059944221\n",
      "2007 年: 167363.1854409063\n",
      "MSE = 33255377.961575348\n"
     ]
    }
   ],
   "source": [
    "AR1 = ARIMA(dlt, order = (1,0,0), missing = \"drop\")\n",
    "# print(AR1)\n",
    "res_AR1 = AR1.fit(method=\"innovations_mle\")\n",
    "print(res_AR1.summary())\n",
    "print(\"\\n\")\n",
    "\n",
    "MA1 = ARIMA(dlt, order = (0,0,1), missing = \"drop\" )\n",
    "res_MA1 = MA1.fit(method = \"innovations_mle\")\n",
    "print(res_MA1.summary())\n",
    "print(\"\\n\")\n",
    "\n",
    "\n",
    "\n",
    "ARIMA11 = ARIMA(dlt, order = (1,0,1), missing = \"drop\" )\n",
    "res_ARIMA11 = ARIMA11.fit(method = \"innovations_mle\")\n",
    "print(res_ARIMA11.summary())\n",
    "\n",
    "pred = res_AR1.forecast(3)\n",
    "cur_log = logtrain[\"EX\"][-1]\n",
    "MSE = 0\n",
    "for idx, i in enumerate(pred):\n",
    "    cur_log += pred[idx]\n",
    "    ori_num = math.exp(cur_log)\n",
    "    print(\"{} 年: {}\".format(2005 + idx, ori_num))\n",
    "    MSE += math.pow( (ori_num - testing[\"EX\"][idx]), 2)\n",
    "print(\"MSE = {}\".format(MSE / 3) )"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3.8.13 ('py38')",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.8.13"
  },
  "latex_envs": {
   "LaTeX_envs_menu_present": true,
   "autoclose": false,
   "autocomplete": true,
   "bibliofile": "biblio.bib",
   "cite_by": "apalike",
   "current_citInitial": 1,
   "eqLabelWithNumbers": true,
   "eqNumInitial": 1,
   "hotkeys": {
    "equation": "Ctrl-E",
    "itemize": "Ctrl-I"
   },
   "labels_anchors": false,
   "latex_user_defs": false,
   "report_style_numbering": false,
   "user_envs_cfg": false
  },
  "toc": {
   "base_numbering": 1,
   "nav_menu": {},
   "number_sections": true,
   "sideBar": true,
   "skip_h1_title": false,
   "title_cell": "Table of Contents",
   "title_sidebar": "Contents",
   "toc_cell": false,
   "toc_position": {},
   "toc_section_display": true,
   "toc_window_display": false
  },
  "vscode": {
   "interpreter": {
    "hash": "da3096a4b2ddf6e3108983d9c4f8ed6b468b54d4f76a60924a980331cf3af984"
   }
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
